package com.syh.jn.scm.domain.supplier.entity.base.upstream;

import cn.redscarf.commons.util.bean.ExtBeanUtils;
import cn.redscarf.commons.util.other.ExtAssert;
import cn.redscarf.commons.util.validator.ValidationUtils;
import com.syh.jn.scm.domain.support.SuperBusinessEntity;
import com.syh.jn.scm.dto.supplier.base.upstream.supplierAddress.UpstreamAddressMto;
import com.syh.jn.scm.dto.supplier.base.upstream.supplierAddress.UpstreamAddressSto;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.util.UUID;

/**
 * 上游供应商 地址
 */
@Data
@EqualsAndHashCode(callSuper = true)
public class UpstreamAddress extends SuperBusinessEntity<Long> {
  /**
   * 新建上游供应商 地址
   *
   * @param dto
   * @return
   */
  public static UpstreamAddress create(UpstreamAddressSto dto) {
    ExtAssert.notNull(dto, "对象为空");
    ValidationUtils.validate(dto);
    UpstreamAddress address = UpstreamAddress.systemCreate(dto);
    address.setUuid(UUID.randomUUID().toString());
    return address;
  }


  /**
   * 修改上游供应商地址
   *
   * @param mto
   */
  public void modify(UpstreamAddressMto mto) {
    ExtAssert.notNull(mto, "对象为空");
    ValidationUtils.validate(mto);
    ExtBeanUtils.copyProperties(mto, this);
  }

  /**
   * 系统默认的字段值
   *
   * @return
   */
  private static UpstreamAddress systemCreate(UpstreamAddressSto dto) {
    UpstreamAddress address = new UpstreamAddress();
    ExtBeanUtils.copyProperties(dto, address);
    address.createDateTimestamp = System.currentTimeMillis();
    return address;
  }

  /**
   * 数据销毁
   */
  public void destroy() {
  }

  /**
   * 对应经营主体id
   */
  private Long businessEntityId;
  /**
   * 地址省 市 区
   */
  private String area;
  /**
   * 地址
   */
  private String address;
  /**
   * 地区编号
   */
  private String areaCode;
  /**
   * 联系人
   */
  private String contacts;
  /**
   * 职务
   */
  private String duties;
  /**
   * 部门
   */
  private String department;
  /**
   * 联系手机
   */
  private String mobile;
  /**
   * 创建日期
   */
  private Long createDateTimestamp;
}
